/**
 * 
 */
package com.webclient.components;

import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;

import com.webclient.WebClent;

/**
 * 窗口关闭按钮
 * qq:297051898
 * @author luxf
 */
public class WindowCloseButton extends JButton {
	private static final long serialVersionUID = 1L;
	public WindowCloseButton(final Window window) {
		setName("WindowCloseButton");
		setCursor(new Cursor(Cursor.HAND_CURSOR));
		setPreferredSize(new Dimension(38, 18));
		addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if (window instanceof WebClent) {
					((WebClent) window).setVisible(false);
					System.exit(0);
				} else if(window instanceof JDialog){
					((JDialog) window).setVisible(false);
				}
			}
		});
	}
}
